package com.itheima.stock.controller;

import com.itheima.stock.api.StockControllerAPI;
import com.itheima.stock.entity.StockBlockRtInfo;
import com.itheima.stock.entity.StockBusiness;
import com.itheima.stock.entity.StockUpdownDomain;
import com.itheima.stock.response.ResponseResult;
import com.itheima.stock.service.StockService;

import com.itheima.stock.vo.InnerMarketVO;
import com.itheima.stock.vo.PageResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zby
 * @created 2024-06-23 16:33
 * @description
 */
@RestController
public class StockController implements StockControllerAPI {

    private final StockService stockService;

    public StockController(StockService stockService) {
        this.stockService = stockService;
    }

    @Override
    public ResponseResult<List<StockBusiness>> getStockBusiness() {
        List<StockBusiness> stockBusiness = stockService.getStockBusiness();
        return ResponseResult.ok(stockBusiness);
    }

    @GetMapping("/index/all")
    public ResponseResult<List<InnerMarketVO>> innerIndexAll(){
        return ResponseResult.ok(stockService.innerIndexAll());
    }

    /**
     *需求说明: 沪深两市板块分时行情数据查询，以交易时间和交易总金额降序查询，取前10条数据
     * @return
     */
    @Override
    public ResponseResult<List<StockBlockRtInfo>> sectorAll(){
        return stockService.sectorAllLimit();
    }

    /**
     * 沪深两市个股涨幅分时行情数据查询，以时间顺序和涨幅查询前10条数据
     * @return
     */
    @Override
    public ResponseResult<List<StockUpdownDomain>> stockIncreaseLimit() {
        return stockService.stockIncreaseLimit();
    }

    /**
     * 沪深两市个股行情列表查询 ,以时间顺序和涨幅分页查询
     * @param page 当前页
     * @param pageSize 每页大小
     * @return
     */
    @Override
    public ResponseResult<PageResult<StockUpdownDomain>> stockPage(Integer page, Integer pageSize) {
        return stockService.stockPage(page, pageSize);
    }

    /**
     * 功能描述：沪深两市涨跌停分时行情数据查询，查询T日每分钟的涨跌停数据（T：当前股票交易日）
     * 		查询每分钟的涨停和跌停的数据的同级；
     * 		如果不在股票的交易日内，那么就统计最近的股票交易下的数据
     * 	 map:
     * 	    upList:涨停数据统计
     * 	    downList:跌停数据统计
     * @return
     */
    @Override
    public ResponseResult<Map> upDownCount() {
        return stockService.upDownCount();
    }

}